package src;

//import java.util.ArrayList;
//import java.util.Collections;
import java.util.List;

/**
 * 
 * @author Patrik Mihalcin
 */
public class Concept implements Comparable<Concept> {
	
//    private static final int SUBKONCEPT = -1;
//    private static final int SUPERKONCEPT = 1;
	
	private List<Double> extent;
	private List<Double> intent;

	public Concept(List<Double> extent, List<Double> intent) {
		this.extent = extent;
		this.intent = intent;
	}

	public List<Double> getExtent() {
		return extent;
	}

	public List<Double> getIntent() {
		return intent;
	}

	@Override
	public String toString() {
		return "{" + extent.toString() + ", " + intent.toString() + "}";
	}

	public int compareTo(Concept concept) {
				
		if (this == concept) {
			return 0;
		}		
//		
////		extent
//		
//		if (this.extent.size() != concept.extent.size()) {
//			throw new RuntimeException("Comparing 2 fuzzy sets: " + extent + " and " +  concept.extent + " which have different number of elements!");
//		}
//		
//		List<Integer> extentComparison = new ArrayList<Integer>();
//		
//		List<Double> thisExtent = new ArrayList<Double>(this.extent);
//		List<Double> conceptExtent = new ArrayList<Double>(concept.extent);
//		Collections.sort(thisExtent);
//		Collections.sort(conceptExtent);
//		
////		for (int i = 0; i < extent.size(); i++) {
////			extentComparison.add(extent.get(i).compareTo(concept.extent.get(i)));
////		}
//		
//		for (int i = 0; i < thisExtent.size(); i++) {
//			extentComparison.add(thisExtent.get(i).compareTo(conceptExtent.get(i)));
//		}
//		
//		if (Collections.frequency(extentComparison, -1) > 0 && Collections.frequency(extentComparison, 1) > 0) {
//			throw new RuntimeException("Comparing 2 extents: " + extent + " and " +  concept.extent + " which are not in subset or superset relation!");	
//		}
//		
////		intent
//		
//		if (this.intent.size() != concept.intent.size()) {
//			throw new RuntimeException("Comparing 2 intents: " + intent + " and " +  concept.intent + " which have different number of elements!");
//		}
//		
//		List<Integer> intentComparison = new ArrayList<Integer>();
//		
//		List<Double> thisIntent = new ArrayList<Double>(this.intent);
//		List<Double> conceptIntent = new ArrayList<Double>(concept.intent);
//		Collections.sort(thisIntent);
//		Collections.sort(conceptIntent);
//		
////		for (int i = 0; i < intent.size(); i++) {
////			intentComparison.add(intent.get(i).compareTo(concept.intent.get(i)));
////		}
//		
//		for (int i = 0; i < thisIntent.size(); i++) {
//			intentComparison.add(thisIntent.get(i).compareTo(conceptIntent.get(i)));
//		}
//		
//		if (Collections.frequency(intentComparison, -1) > 0 && Collections.frequency(intentComparison, 1) > 0) {
//			throw new RuntimeException("Comparing 2 extents: " + extent + " and " +  concept.extent + " which are not in subset or superset relation!");	
//		}
//		
//		if (Collections.frequency(extentComparison, -1) > 0 && Collections.frequency(intentComparison, 1) > 0) {
//			return -1;
//		}
//		
//		if (Collections.frequency(extentComparison, 1) > 0 && Collections.frequency(intentComparison, -1) > 0) {
//			return 1;
//		}
//		
//		return 0;
		
		//different approach
		
//		for (int i = 0; i < extent.size(); i++) {
//			if (extent.get(i).compareTo(concept.extent.get(i)) == SUPERKONCEPT) { 
//				return SUPERKONCEPT;				
//			}
//			if (extent.get(i).compareTo(concept.extent.get(i)) == SUBKONCEPT) { 
//				return SUBKONCEPT;				
//			}
//		}
//		
//		for (int i = 0; i < intent.size(); i++) {
//			if (intent.get(i).compareTo(concept.intent.get(i)) == SUBKONCEPT) {
//				return SUBKONCEPT;				
//			}
//			if (intent.get(i).compareTo(concept.intent.get(i)) == SUPERKONCEPT) {
//				return SUPERKONCEPT;				
//			}
//		}
//		
		return 0;		
	}

//	@Override
//	public int hashCode() {
//		final int prime = 31;
//		int result = 1;
//		result = prime * result + ((extent == null) ? 0 : extent.hashCode());
//		result = prime * result + ((intent == null) ? 0 : intent.hashCode());
//		return result;
//	}
//
//	@Override
//	public boolean equals(Object obj) {
//		if (this == obj)
//			return true;
//		if (obj == null)
//			return false;
//		if (getClass() != obj.getClass())
//			return false;
//		Concept other = (Concept) obj;
//		if (extent == null) {
//			if (other.extent != null)
//				return false;
//		} else if (!extent.equals(other.extent))
//			return false;
//		if (intent == null) {
//			if (other.intent != null)
//				return false;
//		} else if (!intent.equals(other.intent))
//			return false;
//		return true;
//	}
}